package com.milo.coding.syncronized;

public class Juc_LockOnObject {

    public static Object object = new Object();

    private Integer stock = 10;

    public void decrStock(){
        // T1,T2
        // 锁是括号里面的对象
        synchronized (object){
            // T0
            --stock;
            if(stock <= 0){
                System.out.println("库存售罄");
                return;
            }
        }
    }
}
